package com.ybkj.daijia.api.driver.v1;

import com.ybkj.daijia.server.model.Company;
import com.ybkj.daijia.server.model.Driver;
import com.ybkj.daijia.server.service.AreaService;
import com.ybkj.daijia.server.service.CompanyService;
import com.ybkj.daijia.server.service.DriverService;
import com.ybkj.daijia.server.service.MemberAccountService;
import com.ybkj.daijia.server.service.MemberService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 司机地区相关
 *
 * @author bo
 */
@Controller("driverAreaController")
@RequestMapping(value = "driver/api/rest/v1")
public class AreaController {

    private static final Logger logger = LoggerFactory.getLogger(AreaController.class);

    @Autowired
    private MemberService memberService;
    @Autowired
    private MemberAccountService memberAccountService;
    @Autowired
    private DriverService driverService;
    @Autowired
    private AreaService areaService;
    @Autowired
    private CompanyService companyService;

    /**
     * 查询地区信息
     */
    @RequestMapping("areaDetail/{driverId}")
    public ModelAndView areaDetail(@PathVariable("driverId") Long driverId) {

        ModelAndView mv = new ModelAndView();

        Driver driver = driverService.findOne(driverId);
        Company company = companyService.findOne(driver.getCompanyId());
//		mv.addObject("area", areaService.findOneWithCharge(company.getAreaId()));
        mv.addObject("company", company);

        mv.setViewName("area/view");

        return mv;
    }

}
